package com.tong.lib.retrofit.okhttp;


import android.util.Log;

import com.tong.lib.BuildConfig;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;

/**
 * Created by hjt on 2019/4/23.
 */

public class InterceptorUtil {

    private static String TAG = "retrofit";

    //日志拦截器
    public static HttpLoggingInterceptor LogInterceptor() {
        return new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
            @Override
            public void log(String message) {
                Log.i(TAG+"——>", message);
            }
        }).setLevel(HttpLoggingInterceptor.Level.BODY);//设置打印数据的级别
    }

    /**
     * 在拦截器加通用请求头
     * @return
     */
    public static Interceptor headerInterceptor() {
        return new Interceptor() {
            @Override
            public Response intercept(Chain chain) throws IOException {
                Request request = chain.request();
                //这边添加
//                Request.Builder builder = request.newBuilder()
//                        .addHeader("Content-Type","");
                return chain.proceed(request);
            }
        };
    }
}
